home *** CD-ROM | disk | FTP | other *** search
/ Network PC / Network PC.iso / amiga utilities / communication / bbs / termv4.6 / extras / source / gtlayout-source.lha / LTP_FracEditRoutine.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-18  |  1.9 KB  |  103 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #ifdef DO_FRACTION_KIND
  15. ULONG __saveds __asm
  16. LTP_FracEditRoutine(REG(a0) struct Hook *Hook,REG(a2) struct SGWork *Work,REG(a1) ULONG *Msg)
  17. {
  18.     if(*Msg == SGH_KEY)
  19.     {
  20.         if(Work->IEvent->ie_Code == 0x5F)
  21.         {
  22.             LayoutHandle *Handle = Hook->h_Data;
  23.  
  24.             if(Handle->HelpHook)
  25.             {
  26.                 Work->Code        = 0x5F;
  27.                 Work->Actions    = (Work->Actions & ~SGA_BEEP) | SGA_END | SGA_USE;
  28.  
  29.                 LTP_AddHistory(Work);
  30.  
  31.                 return(TRUE);
  32.             }
  33.         }
  34.  
  35.         if(Work->IEvent->ie_Code == CURSORUP || Work->IEvent->ie_Code == CURSORDOWN)
  36.             LTP_HandleHistory(Work);
  37.  
  38.         if(Work->EditOp == EO_ENTER)
  39.         {
  40.             LayoutHandle    *Handle = Hook->h_Data;
  41.             ObjectNode        *Node;
  42.             BOOL              Activate = TRUE;
  43.  
  44.             if(GETOBJECT(Work->Gadget,Node))
  45.             {
  46.                 if(Node->Type == FRACTION_KIND && Node->Special.String.LastGadget)
  47.                     Activate = FALSE;
  48.             }
  49.  
  50.             if(!(Work->IEvent->ie_Qualifier & QUALIFIER_SHIFT))
  51.             {
  52.                 if(Activate && Handle->AutoActivate)
  53.                     Work->Actions |= SGA_NEXTACTIVE;
  54.  
  55.                 if(!(Work->Actions & SGA_NEXTACTIVE))
  56.                     Work->Code = '\r';
  57.             }
  58.         }
  59.  
  60.         if(Work->EditOp == EO_INSERTCHAR || Work->EditOp == EO_REPLACECHAR)
  61.         {
  62.             LONG DecimalPoint = (LTP_Locale ? LTP_Locale->loc_DecimalPoint[0] : '.');
  63.  
  64.             if(Work->Code == DecimalPoint || (Work->Code >= '0' && Work->Code <= '9'))
  65.             {
  66.                 if(Work->Code == DecimalPoint)
  67.                 {
  68.                     LONG i;
  69.                     BOOL UseIt = TRUE;
  70.  
  71.                     for (i = 0 ; UseIt && i < Work->NumChars ; i++)
  72.                     {
  73.                         if(Work->PrevBuffer[i] == DecimalPoint)
  74.                             UseIt = FALSE;
  75.                     }
  76.  
  77.                     if(!UseIt)
  78.                     {
  79.                         Work->Actions &= ~SGA_USE;
  80.                         Work->Actions |=  SGA_BEEP;
  81.                     }
  82.                 }
  83.             }
  84.             else
  85.             {
  86.                 Work->Actions &= ~SGA_USE;
  87.                 Work->Actions |=  SGA_BEEP;
  88.             }
  89.         }
  90.  
  91.         if(Work->Actions & SGA_END)
  92.             LTP_AddHistory(Work);
  93.     }
  94.     else
  95.     {
  96.         if(*Msg != SGH_CLICK)
  97.             return(FALSE);
  98.     }
  99.  
  100.     return(TRUE);
  101. }
  102. #endif
  103.